import EffectCommon from 'code/Core/Common/EffectCommon';
import MathCommon from 'code/Core/Common/MathCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 闪电链
 **/
export default class SM_Lightings extends AbilityBase {
    static instance: SM_Lightings;
    constructor(id: string = 'Asdl') {
        super(id);
        SM_Lightings.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let loop = MathCommon.getAbilityEffectCount(5, source, this.id);
        EffectCommon.lighting({
            target,
            caster: source,
            onTach: this.onTach.bind(this),
            loop,
        });
    }
    onTach(p: lightingParams, cur: unit) {
        let lv = this.getAbilityLevel(p.caster);
        let dmg = 35 * lv + UnitCommon.取法强(p.caster) * (0.65 + 0.25 * lv);
        DamageSystemInstance.applyLightingDamage(cur, p.caster, dmg, this.id);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
